/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package imp.reciever;

import dom.Reciever;
import imp.reciever.input.ReadFolder;
import imp.reciever.output.SaveFiles;
import imp.reciever.process.Decrypt;
import imp.reciever.process.Encrypt;
import imp.reciever.process.ExecuteSH;
import imp.reciever.process.Unzip;
import java.io.InputStream;
import java.io.OutputStream;

/**
 *
 * @author julian.pena
 */
public class RecieverFactory {
    
    public static RecieverType[] getTypes(){
        return RecieverType.values();
    }
    
    public static RecieverName[] getRecievers(){
        return RecieverName.values();
    }
    
    public static RecieverName[] getRecievers(RecieverType rt){
        RecieverName[] names = null;
        if (rt == RecieverType.INPUT) {
            names = new RecieverName[1];
            names[0] = RecieverName.READ_FODER;
        } else if(rt == RecieverType.PROCESS){
            names = new RecieverName[5];
            names[0] = RecieverName.ENCRYPT;
            names[1] = RecieverName.DECRYPT;
            names[2] = RecieverName.EXECUTE_SCRIPT;
            names[3] = RecieverName.COMPRESS;
            names[4] = RecieverName.DECOMPRESS;
        } else if(rt == RecieverType.OUTPUT){
            names = new RecieverName[1];
            names[0] = RecieverName.SAVE_FILES;
        }
        return names;
    }
    
    public static Reciever getReciever(RecieverName rn, Object[] params) throws Exception{
        Reciever reciever = null;
        if (rn == RecieverName.READ_FODER) {
            reciever =  new ReadFolder((String)params[0]);
        } else if (rn == RecieverName.ENCRYPT) {
            reciever =  new Encrypt((InputStream)params[0], (OutputStream)params[1]);
        } else if (rn == RecieverName.DECRYPT) {
            reciever =  new Decrypt((InputStream)params[0], (OutputStream)params[1]);
        } else if (rn == RecieverName.EXECUTE_SCRIPT) {
            reciever =  new ExecuteSH((String)params[0]);
        } else if (rn == RecieverName.SAVE_FILES) {
            reciever =  new SaveFiles((String)params[0]);
        } else if (rn == RecieverName.DECOMPRESS) {
            reciever =  new Unzip();
        } 
        return reciever;
    }
}
